//
//  BattleGroupInfo.m
//  SpaceStorm
//
//  Created by 祥 雍 on 13-5-26.
//  Copyright (c) 2013年 __MyCompanyName__. All rights reserved.
//
//  战斗组表的信息类

#import "BattleGroupInfo.h"
#import "Variable.h"

@implementation BattleGroupInfo

@synthesize groupId     = _groupId;
@synthesize ship1       = _ship1;
@synthesize ship2       = _ship2;
@synthesize ship3       = _ship3;
@synthesize ship4       = _ship4;
@synthesize ship5       = _ship5;
@synthesize ship6       = _ship6;
@synthesize ship7       = _ship7;
@synthesize ship8       = _ship8;
@synthesize shipIDs     = _shipIDs;

+(id) infoWithTbxml:(TBXMLElement *)tbxml
{
    return [[[self alloc] initWithTbxml:tbxml] autorelease]; 
}


-(id) initWithTbxml:(TBXMLElement *)tbxml
{
    self = [super init]; 
	
	if (self!= nil) 
    {
        self.shipIDs = [CCArray array];
        
        //战斗组id
        self.groupId = [[TBXML valueOfAttributeNamed:@"groupId" forElement:tbxml] intValue];
        if(showXMLLog == YES) CCLOG(@"战斗组id:%d", self.groupId);
        
        //舰船1	
        self.ship1 = [[TBXML valueOfAttributeNamed:@"ship1" forElement:tbxml] intValue];
        if (self.ship1 != 0)//不为0的shipID保存到数组
        {
            [self.shipIDs addObject:[NSNumber numberWithInt:self.ship1]];
        }
        if(showXMLLog == YES) CCLOG(@"舰船1:%d", self.ship1);
        
        //舰船2	
        self.ship2 = [[TBXML valueOfAttributeNamed:@"ship2" forElement:tbxml] intValue];
        if (self.ship2 != 0)//不为0的shipID保存到数组
        {
            [self.shipIDs addObject:[NSNumber numberWithInt:self.ship2]];
        }
        if(showXMLLog == YES) CCLOG(@"舰船2:%d", self.ship2);
        
        //舰船3	
        self.ship3 = [[TBXML valueOfAttributeNamed:@"ship3" forElement:tbxml] intValue];
        if (self.ship3 != 0)//不为0的shipID保存到数组
        {
            [self.shipIDs addObject:[NSNumber numberWithInt:self.ship3]];
        }
        if(showXMLLog == YES) CCLOG(@"舰船3:%d", self.ship3);
        
        //舰船4	
        self.ship4 = [[TBXML valueOfAttributeNamed:@"ship4" forElement:tbxml] intValue];
        if (self.ship4 != 0)//不为0的shipID保存到数组
        {
            [self.shipIDs addObject:[NSNumber numberWithInt:self.ship4]];
        }
        if(showXMLLog == YES) CCLOG(@"舰船4:%d", self.ship4);
        
        //舰船5	
        self.ship5 = [[TBXML valueOfAttributeNamed:@"ship5" forElement:tbxml] intValue];
        if (self.ship5 != 0)//不为0的shipID保存到数组
        {
            [self.shipIDs addObject:[NSNumber numberWithInt:self.ship5]];
        }
        if(showXMLLog == YES) CCLOG(@"舰船5:%d", self.ship5);
        
        //舰船6	
        self.ship6 = [[TBXML valueOfAttributeNamed:@"ship6" forElement:tbxml] intValue];
        if (self.ship6 != 0)//不为0的shipID保存到数组
        {
            [self.shipIDs addObject:[NSNumber numberWithInt:self.ship6]];
        }
        if(showXMLLog == YES) CCLOG(@"舰船6:%d", self.ship6);
        
        //舰船7	
        self.ship7 = [[TBXML valueOfAttributeNamed:@"ship7" forElement:tbxml] intValue];
        if (self.ship7 != 0)//不为0的shipID保存到数组
        {
            [self.shipIDs addObject:[NSNumber numberWithInt:self.ship7]];
        }
        if(showXMLLog == YES) CCLOG(@"舰船7:%d", self.ship7);
        
        //舰船8	
        self.ship8 = [[TBXML valueOfAttributeNamed:@"ship8" forElement:tbxml] intValue];
        if (self.ship8 != 0)//不为0的shipID保存到数组
        {
            [self.shipIDs addObject:[NSNumber numberWithInt:self.ship8]];
        }
        if(showXMLLog == YES) CCLOG(@"舰船8:%d", self.ship8);
    }
    
    return self;
}

@end
